package com.xuelang.pipeline.client.pipeline;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.dto.GroupDTO;
import com.xuelang.pipeline.client.pipeline.dto.GroupQuery;
import com.xuelang.pipeline.client.pipeline.dto.PipelineGroupQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 流水线分组服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface IGroupService {

    /**
     * 查询流水线分组列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<GroupDTO>> pageGroupList(@RequestBody @Valid PageParam<GroupQuery> dtoPageParam);

    /**
     * 查询流水线分组列表(有过滤条件)
     *
     * @param groupQuery
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<GroupDTO>> conditionalGroupList(@RequestBody @Valid GroupQuery groupQuery);

    /**
     * 新增流水线分组
     *
     * @param groupDTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addGroup(@RequestBody @Valid GroupDTO groupDTO);

    /**
     * 批量新增/更新流水线分组
     * @param groupDTOList
     * @return
     */
    @PostMapping(value = "/batchSaveOrUpdate", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> batchSaveOrUpdate(@RequestBody List<GroupDTO> groupDTOList);

    /**
     * 更新流水线分组
     *
     * @param groupDTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateGroup(@RequestBody @Valid GroupDTO groupDTO);

    /**
     * 删除流水线分组
     *
     * @param uuid
     * @return
     */
    @DeleteMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteGroup(@PathVariable("uuid") String uuid);

    /**
     * 查询流水线分组
     *
     * @param uuid
     * @return
     */
    @GetMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<GroupDTO> queryGroup(@PathVariable("uuid") String uuid);


    /**
     * 流水线分组变更
     * @param query
     * @return
     */
    @PostMapping(value = "/modifyPipelineGroups", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> modifyPipelineGroups(@RequestBody @Valid PipelineGroupQuery query);

    /**
     * 收藏流水线
     * @param pipelineCode
     * @return
     */
    @PostMapping(value = "/addFavoritePipeline", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addFavoritePipeline(@RequestParam("code") String pipelineCode);

    /**
     * 取消收藏流水线
     * @param pipelineCode
     * @return
     */
    @PostMapping(value = "/removeFavoritePipeline", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> removeFavoritePipeline(@RequestParam("code") String pipelineCode);
}
